/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import javax.swing.JOptionPane;

/**
 *
 * @author juan
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnl_Opciones = new javax.swing.JPanel();
        rbtn_Congruencial = new javax.swing.JRadioButton();
        rbtn_Lenguaje = new javax.swing.JRadioButton();
        btn_Aceptar = new javax.swing.JButton();
        btn_Salir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Random");

        pnl_Opciones.setBorder(javax.swing.BorderFactory.createTitledBorder("Elija una opción"));

        rbtn_Congruencial.setText("Generador Congruencial");
        rbtn_Congruencial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtn_CongruencialActionPerformed(evt);
            }
        });

        rbtn_Lenguaje.setText("Generador del Lengüaje");
        rbtn_Lenguaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtn_LenguajeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnl_OpcionesLayout = new javax.swing.GroupLayout(pnl_Opciones);
        pnl_Opciones.setLayout(pnl_OpcionesLayout);
        pnl_OpcionesLayout.setHorizontalGroup(
            pnl_OpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_OpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnl_OpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rbtn_Congruencial)
                    .addComponent(rbtn_Lenguaje))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnl_OpcionesLayout.setVerticalGroup(
            pnl_OpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_OpcionesLayout.createSequentialGroup()
                .addComponent(rbtn_Congruencial)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbtn_Lenguaje))
        );

        btn_Aceptar.setText("Aceptar");
        btn_Aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_AceptarActionPerformed(evt);
            }
        });

        btn_Salir.setText("Salir");
        btn_Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnl_Opciones, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btn_Salir, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_Aceptar)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btn_Aceptar, btn_Salir});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnl_Opciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_Aceptar)
                    .addComponent(btn_Salir))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btn_Aceptar, btn_Salir});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rbtn_CongruencialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtn_CongruencialActionPerformed
       this.rbtn_Lenguaje.setSelected(false);
       this.rbtn_Congruencial.setSelected(true);
    }//GEN-LAST:event_rbtn_CongruencialActionPerformed

    private void rbtn_LenguajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtn_LenguajeActionPerformed
        this.rbtn_Lenguaje.setSelected(true);
       this.rbtn_Congruencial.setSelected(false);
    }//GEN-LAST:event_rbtn_LenguajeActionPerformed

    private void btn_AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_AceptarActionPerformed
        if (this.rbtn_Congruencial.isSelected()==true || this.rbtn_Lenguaje.isSelected()==true) {
            
            if (this.rbtn_Congruencial.isSelected()==true){
                VistaGenerador miVista = new VistaGenerador();
                miVista.setVisible(true);
                this.setVisible(false);
            }
            if (this.rbtn_Lenguaje.isSelected()==true){
                FrecuenciaRandomLenguaje frec = new FrecuenciaRandomLenguaje();
                frec.setVisible(true);
                this.setVisible(false);
            }
        }
        else
            JOptionPane.showMessageDialog(Principal.super.getContentPane(), "Debe seleccionar una de las opciones.", "Importante", JOptionPane.INFORMATION_MESSAGE);
        
    }//GEN-LAST:event_btn_AceptarActionPerformed

    private void btn_SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SalirActionPerformed
        this.setDefaultCloseOperation(Principal.EXIT_ON_CLOSE);
        this.dispose();
    }//GEN-LAST:event_btn_SalirActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Aceptar;
    private javax.swing.JButton btn_Salir;
    private javax.swing.JPanel pnl_Opciones;
    private javax.swing.JRadioButton rbtn_Congruencial;
    private javax.swing.JRadioButton rbtn_Lenguaje;
    // End of variables declaration//GEN-END:variables
}
